/* inw.t   INVENTORY MASTER WRITE TRIGGER                             */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :inw.t                                                   */
/*  Author  :Ben Holmes                                              */
/*  Date    :03/19/95                                                */
/*  !Description : in_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  03/19/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.6          Last Modified:  11/20/96 BY: cjv     *K01B*  */
/*Revision 8.6          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  08/13/00 BY: *N0KR* myb       */
/*Revision 9.1          Last Modified:  11/14/00 BY: *N0TS* Robert Jensen */
/*Revision 9.0          Last Modified:  05/27/02 BY: *M1Z1* Deirdre O'Brien */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF IN_MSTR OLD BUFFER OLD_IN_MSTR.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

        {mfdeclre.i }
        define new shared work-table wf_old_in_mstr like in_mstr.
        define new shared variable w-recid as recid.
        define variable w-file as character format "x(24)".


        /* Warehousing Interface processing */

        WI:
        do:

        /* If there is no active external warehouse, then do not process */
/*K01B     If the item export flag is not set, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*K01B  /*J12B*/        where whl_mstr.whl_act) */
/*K01B*/          where whl_mstr.whl_act
/*K01B*/          and whl_mstr.whl_pt_exp)
/*J12B*/    then leave WI.

        /* If no pertinent fields have been changed, then do not process */
/*J12B*/    if   (old_in_mstr.in_part         = in_mstr.in_part
/*J12B*/      and old_in_mstr.in_abc          = in_mstr.in_abc
/*J12B*/      and old_in_mstr.in_cyc_int      = in_mstr.in_cyc_int
/*J12B*/      and old_in_mstr.in_rctpo_status = in_mstr.in_rctpo_status
/*J12B*/      and old_in_mstr.in_user1        = in_mstr.in_user1
/*J12B*/      and old_in_mstr.in_user2        = in_mstr.in_user2)
/*J12B*/    then leave WI.

        /* Move old in_mstr values to work table for subsequent processing */
            assign w-recid = recid(in_mstr).
            create wf_old_in_mstr.
            if recid(wf_old_in_mstr)= -1 then .
            assign
                wf_old_in_mstr.in_part         = old_in_mstr.in_part
                wf_old_in_mstr.in_abc          = old_in_mstr.in_abc
                wf_old_in_mstr.in_cyc_int      = old_in_mstr.in_cyc_int
                wf_old_in_mstr.in_rctpo_status = old_in_mstr.in_rctpo_status
                wf_old_in_mstr.in_user1        = old_in_mstr.in_user1
                wf_old_in_mstr.in_user2        = old_in_mstr.in_user2
            .

        /* Call subprogram to create export transactions for warehouses */
            w-file = "wiinw.p".
/*J1DM*/ /* {gprun.i ""wiinw.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wiinw.p"}

/*J12B*/end. /* WI */
/*N0TS*//* Logistics Interface processing */
/*N0TS*/LG:
/*N0TS*/do:
/*N0TS*//* If there is no logistics application ID, then do not process */
/*N0TS*/      if not can-find(first lgs_mstr no-lock
/*N0TS*/        where lgs_app_id <> "")
/*N0TS*/           then leave LG.
/*N0TS*/   for first soc_ctrl fields(soc_on_ord soc_req) no-lock:
/*N0TS*/   end.
         /*M1Z1*/ /* Create wf_old_in_mstr record if one doesn't exist*/
/*M1Z1*/   if not available wf_old_in_mstr then
/*M1Z1*/   do:
/*M1Z1*/      assign w-recid = recid(in_mstr).
/*M1Z1*/      create wf_old_in_mstr.
/*M1Z1*/      if recid(wf_old_in_mstr)= -1 then .
/*M1Z1*/      assign
/*M1Z1*/         wf_old_in_mstr.in_part         = old_in_mstr.in_part
/*M1Z1*/         wf_old_in_mstr.in_abc          = old_in_mstr.in_abc
/*M1Z1*/         wf_old_in_mstr.in_cyc_int      = old_in_mstr.in_cyc_int
/*M1Z1*/         wf_old_in_mstr.in_rctpo_status = old_in_mstr.in_rctpo_status
/*M1Z1*/         wf_old_in_mstr.in_user1        = old_in_mstr.in_user1
/*M1Z1*/         wf_old_in_mstr.in_user2        = old_in_mstr.in_user2.

/*M1Z1*/   end.
/*M1Z1*/   assign
/*M1Z1*/      wf_old_in_mstr.in_qty_req = old_in_mstr.in_qty_req
/*M1Z1*/      wf_old_in_mstr.in_qty_ord = old_in_mstr.in_qty_ord.

/*N0TS*//* If no pertinent fields have been changed, then do not process */
/*N0TS*/   if (old_in_mstr.in_qty_avail <> in_mstr.in_qty_avail) or
/*N0TS*/      (old_in_mstr.in_qty_all <> in_mstr.in_qty_all) or
              ((soc_req) and (in_mstr.in_qty_req <> wf_old_in_mstr.in_qty_req)) or
              ((soc_on_ord) and (in_mstr.in_qty_ord <> wf_old_in_mstr.in_qty_ord))
/*N0TS*/   then do:
/*N0TS*//*    Move old in_mstr values to work table for subsequent processing */
/*N0TS*/      if not can-find(first wf_old_in_mstr) then do:
/*N0TS*/         create wf_old_in_mstr.
/*N0TS*/         if recid(wf_old_in_mstr)= -1 then .
/*N0TS*/      end.
/*N0TS*/      buffer-copy old_in_mstr to wf_old_in_mstr no-error.
/*N0TS*/      /* Call subprogram to publish changed status for Logistics */
/*N0TS*/      {gprunmo.i &module="LG"
/*N0TS*/      &program="lgldex.p"
/*N0TS*/      &param="""(input recid(in_mstr))"""}
/*N0TS*/   end.
/*N0TS*/end. /* LG */
/*N0TS* *End of Added Section */
